#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "GLDisplay.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionWireFrame, SIGNAL(toggled(bool)), this, SIGNAL(wireframeClicked(bool)));
    connect(ui->actionLight_Rotation, SIGNAL(toggled(bool)), this, SIGNAL(lightRotationToggle(bool)));
    connect(ui->actionSaveImageAs, SIGNAL(triggered()), this, SIGNAL(saveResultAsImage()));
    connect(ui->radioObj1, SIGNAL(clicked(bool)), this, SLOT(radio(bool)));
    connect(ui->radioObj2, SIGNAL(clicked(bool)), this, SLOT(radio(bool)));
    connect(ui->radioObj3, SIGNAL(clicked(bool)), this, SLOT(radio(bool)));
    connect(ui->mudarCor, SIGNAL(clicked(bool)), this, SLOT(valorCores()));
    connect(ui->mudarEscala, SIGNAL(clicked(bool)), this, SLOT(valorEscalas()));
    connect(ui->mudarTranslacao, SIGNAL(clicked(bool)), this, SLOT(valorTranslacoes()));
   // connect(ui->shaderCubo, SIGNAL(toggled(bool)), this, SLOT(shaderSelected(bool)));
    connect(ui->shaderCubo,SIGNAL(clicked(bool)), this, SLOT(shaderSelected(bool)));

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::setGLDisplay(GLDisplay *display)
{
    ui->verticalLayout->addWidget(display);
}

void MainWindow::radio(bool)
{
    emit radioEvent(ui->radioObj1->isChecked(), ui->radioObj2->isChecked(),ui->radioObj3->isChecked());
}
void MainWindow::valorCores()
{
    emit aplicaCores(ui->lineRed->text().toInt() ,ui->lineGreen->text().toInt(),ui->lineBlue->text().toInt());
}
void MainWindow::valorEscalas()
{
    emit aplicaEscalas(ui->lineEscalaX->text().toFloat(),ui->lineEscalaY->text().toFloat(),ui->lineEscalaZ->text().toFloat());
}
void MainWindow::valorTranslacoes()
{
    emit aplicaTranslacoes(ui->spinBoxX->text().toDouble(),ui->spinBoxY->text().toDouble(),ui->spinBoxZ->text().toDouble());
}
void MainWindow::shaderSelected(bool){
    emit shaderLigado(ui->shaderCubo->isChecked());
}

